﻿/// <reference path="../GeneratedArtifacts/viewModel.js" />

myapp.BrowsePatients.AddNewPatient_execute = function (screen) {
    // Open the AddNewPatient Screen
    myapp.showAddNewPatient({
        beforeShown: function (addEditPatientScreen) {
            // Create new Patient here so that
            // discard will work.
            var newPatient = new myapp.Patient;
            addEditPatientScreen.Patient = newPatient;
        },
        afterClosed: function (AddNewPatientScreen, navigationAction) {
            // Refresh Patients
            screen.Patients.load();
        }
    });
};
myapp.BrowsePatients.EditPatient_execute = function (screen) {
    // Set the scrollTopPosition
    var scrollTopPosition = $(window).scrollTop();
    // Open the Edit Screen
    myapp.showAddEditPatient(screen.Patients.selectedItem, {
        afterClosed: function () {
            // After the Edit screen is closed 
            // scroll to the saved scrollTopPosition
            $(window).scrollTop(scrollTopPosition);
        }
    });
};
